package matrix;

import java.util.ArrayList;
import java.util.List;

public class Solution_74 {

    public boolean searchMatrix(int[][] matrix, int target) {
        List<Integer> list = new ArrayList<>();
        for (int[] ints : matrix) {
            for (int i : ints) {
                list.add(i);
            }
        }

        int left=0,right=list.size()-1;
        while(left<=right){
            int mid=(left+right)>>>1;
            if(list.get(mid)==target)
                return true;
            if(list.get(mid)<target)
                left=mid+1;
            else
                right=mid-1;
        }
        return false;
    }
}
